#!/bin/bash
set -eo pipefail
runday="{{ execution_date | date_add(-13) | cst_ds }}"
cd /opt/export/

# 紫金山逍遥峰退转明细定时导出

hdfs dfs -get -f /report/紫金山逍遥峰退转明细/紫金山逍遥峰退转明细_$runday  /opt/export/紫金山逍遥峰退转明细_$runday

zip /opt/export/紫金山逍遥峰退转明细_$runday.zip  /opt/export/紫金山逍遥峰退转明细_$runday/*

/usr/local/python3/bin/python3  /usr/local/airflow/dags/utils/operators/upload_oss.py  紫金山逍遥峰退转明细/紫金山逍遥峰退转明细_$runday.zip  紫金山逍遥峰退转明细_$runday.zip

data_size=$(ls -lh 紫金山逍遥峰退转明细_$runday.zip | awk '{print $5}')
Message="紫金山逍遥峰退转明细_$runday 报表上传成功 大小: $data_size"

curl 'https://oapi.dingtalk.com/robot/send?access_token=816a8f35fd84432ffa6bff9d7714abc322628bb4a8ded86908550d2335aba613' \
   -H 'Content-Type: application/json' \
   -d "
  {\"msgtype\": \"text\",
    \"text\": {
        \"content\": \"监控内容:$Message\"
     }
  }" || true

rm -rf /opt/export/紫金山逍遥峰退转明细_$runday
rm -rf /opt/export/紫金山逍遥峰退转明细_$runday.zip